package tinybase.pf;

import tinybase.basic.BytePointer;
import tinybase.basic.RC;

public class PF_PageHandle {
	
	public static final int INVALID_PAGENUM = -1;
	private byte[] refData;
	private int pageNum;
	
	public PF_PageHandle() {
		pageNum = PF_PageHandle.INVALID_PAGENUM;
		refData = null;
	}
	
	public RC getData(BytePointer ptr) {
		ptr.setArray(refData);
		return RC.PF_SUCCESS;
	}
	
	public RC getPageNum(PageNum refPageNum) {
		if (refData == null)
			return RC.PF_PAGEUNPINNED;
		refPageNum.setPageNum(this.pageNum);
		return RC.PF_SUCCESS;
	}
	
	public void setData(byte[] data) {
		this.refData = data;
	}
	
	public void setPageNum(int val) {
		this.pageNum = val;
	}
}